package cn.bdqn.service.impl;

import java.util.List;

import cn.bdqn.dao.NewsCategoryDao;
import cn.bdqn.dao.NewsDao;
import cn.bdqn.dao.impl.NewsCategoryDaoImpl;
import cn.bdqn.dao.impl.NewsDaoImpl;
import cn.bdqn.pojo.NewsCategory;
import cn.bdqn.service.NewsCategoryService;

public class NewsCategoryServiceImpl implements NewsCategoryService {

	private NewsDao newsDao = null;
	private NewsCategoryDao newsCategoryDao = null;
	
	public NewsCategoryServiceImpl(){
		newsDao = new NewsDaoImpl();
		newsCategoryDao = new NewsCategoryDaoImpl();
	}
	
	
	/**
	 * 删除新闻分类，若在detail表中该分类下有数据，则提示不能删除
	 * 若无数据，直接删除
	 */
	@Override
	public boolean delNewsCategory(NewsCategory newsCategory) {
		// TODO Auto-generated method stub
		boolean flag = false;
		int count = newsDao.getNewsCountByCategoryId(newsCategory);
		if(count > 0){
			System.out.println("该类别下有新闻信息数据，不能进行类别删除！");
		}else{
			flag = newsCategoryDao.delNewsCategory(newsCategory);
		}
		return flag;
	}


	@Override
	public List<NewsCategory> getNewsCategoryList() {
		// TODO Auto-generated method stub
		return newsCategoryDao.getNewsCategoryList();
	}

}
